<?php

class GalleriesItems extends Eloquent {
   
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'galleries_items';

    /**
     * The primary key for the model.
     *
     * @var string
     */
    protected $primaryKey = 'id';
    protected $fillable = array('galleryID', 'itemID', 'type', 'order', 'userID_created','userID_modified');
    
    public function delete(array $options = array()) {
        $item = parent::delete($options);
        switch($this->type)
        {
            case "video":
                $video = \Videos::find($this->itemID);
                $video->delete();            
            break;
            case "image":
                $image = \Images::find($this->itemID);
                $image->delete();
            break;
        }
        return true;
    }
   
}

